home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / easelChar.lua < prev    next >
Text File  |  2004-01-29  |  3KB  |  103 lines

  1. -- easel character state machine
  2. beginStateMachine()
  3.     
  4.     onEnter(function(msg)
  5.         local easel = getStateObjectFromID(msg.sender);
  6.         storeStateObject("easel", easel);
  7.         
  8.         if (easel) then
  9.             -- easel does exist
  10.             if (getParent().isOneActionPointLocked(easel)) then
  11.                 -- action point is locked
  12.                 getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  13.                 sendMsg("emoThink", getParent().walkSO);
  14.                 exitStateMachine();
  15.             else
  16.                 getParent().lockActionPoints(easel);
  17.             end
  18.         else
  19.             -- easel does not exist anymore
  20.             getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  21.             sendMsg("emoThink", getParent().walkSO);
  22.             exitStateMachine();
  23.         end
  24.         
  25.         freeHands(getParent());
  26.                 
  27.     end )
  28.     
  29.     onExit(function(msg)
  30. --        local easel = retrieveStateObject("easel");
  31. --        getParent().unlockActionPoints(easel);
  32. --        getParent().stopAllActivities(easel);
  33. --        removeStateObject("easel");
  34.         
  35.         unlockAll("easel");        
  36.     end )
  37.     
  38.     state("paint")
  39.     
  40.         onEnter(function(msg)
  41.         
  42.             local brush = getParent().loadGameObject("StandardGO","paintbrush");
  43.             storeStateObject("brush", brush);
  44.             getParent().attachRightObjectHolder(brush);        
  45.         
  46.             local palette = getParent().loadGameObject("StandardGO","palette");
  47.             storeStateObject("palette", palette);
  48.             getParent().attachLeftObjectHolder(palette);        
  49.         
  50.             local easel = retrieveStateObject("easel");
  51.         
  52.             startAnimation("paint");
  53.             
  54.             local paintActivity = getParent().startActivity("paint", easel);
  55.             local length, scale = getActivityLength(paintActivity);
  56.  
  57. --            this.actionComplete();
  58.             sendDelayedMsgThis("stopPainting", length);
  59.             sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
  60.             
  61.         end )
  62.     
  63.         onMsg("stopPainting", function(msg)
  64.  
  65.             getParent().detachRightObjectHolder();    
  66.             local brush = retrieveStateObject("brush");
  67.             if (brush) then brush.deleteGameObject(); end
  68.  
  69.             getParent().detachLeftObjectHolder();    
  70.             local palette = retrieveStateObject("palette");
  71.             if (palette) then palette.deleteGameObject(); end
  72.  
  73.             local easel = retrieveStateObject("easel");
  74.             getParent().stopActivity("paint", easel);
  75.             
  76.             exitStateMachine();
  77.         end )    
  78.         
  79. --        onMsg("queue", function(msg)
  80. --            sendMsgThis("stopPainting");
  81. --        end )
  82.         
  83.         onMsg("testCancel", function(msg)
  84.             if testCancel() and (not this.getParent().getCurrentActivityGain()) then
  85.                 sendMsgThis("stopPainting");
  86.             else
  87.                 sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
  88.             end
  89.         end )
  90.         
  91.  
  92.         onMsg("end", function(msg)
  93.             if testCancel() then
  94.                 sendMsgThis("stopPainting");
  95.             else
  96.                 startAnimation("paint");
  97.             end
  98.         end )    
  99.         
  100.  
  101.                 
  102. endStateMachine()
  103.